package com.dengqi.mymodule.activity.network.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.dengqi.mymodule.R;
import com.dengqi.mymodule.activity.network.adapter.BaseAdapter;
import com.dengqi.mymodule.activity.network.adapter.CardAdapter;
import com.dengqi.mymodule.activity.network.bean.CardBean;
import com.dengqi.mymodule.activity.network.bean.ServiceBean;
import com.dengqi.mymodule.activity.network.module.CardContract;
import com.dengqi.mymodule.activity.network.module.CardPresenter;
import com.trello.rxlifecycle2.components.support.RxAppCompatActivity;

import java.util.List;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

/**
 * @Author: dengqi
 * @CreateDate: 2020/10/19 17:25
 * @Description: 单项目列表
 */
public class SingleListActivity extends RxAppCompatActivity implements CardContract.CardView {

    private RecyclerView recyclerView;
    private CardAdapter<ServiceBean> adapter;

    private CardPresenter cardPresenter;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_single_list);

        cardPresenter = new CardPresenter(this);

        recyclerView = findViewById(R.id.recyclerView);
        adapter = new CardAdapter<>();
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.setAdapter(adapter);
        adapter.setOnItemClickListener(new BaseAdapter.OnItemClickListener<ServiceBean>() {
            @Override
            public void onItemClick(View v, int position, ServiceBean mode) {
                startActivity(new Intent(SingleListActivity.this, SingleListActivity.class));
            }
        });

        cardPresenter.getCardList(this);
    }

    @Override
    public String getShopId() {
        return "1";
    }

    @Override
    public String getStatus_() {
        return "2";
    }

    @Override
    public String getCardType() {
        return "1";
    }

    @Override
    public void onCardList(List<CardBean> result) {

    }

    @Override
    public void onServiceList(List<ServiceBean> result) {
        adapter.setData(result);
        adapter.notifyDataSetChanged();
    }

}
